package edu.cuit.avatar.array;

/**
 * @author <a href="mailto:1020zhaodan@163.com">Adan</a>
 * @version 1.0
 * @date 2025/7/4 8:49
 */
public class 二维数组 {
    public static void main(String[] args) {
        int[][] matrix = new int[4][5];
        System.out.println(matrix.length); //4
        System.out.println(matrix[0].length); //5
        System.out.println(matrix[1].length); //5
        System.out.println(matrix[2].length); //5
        System.out.println(matrix[3].length); //5

        int[][] triangle = new int[5][];
        triangle[0] = new int[]{5,4,3,2,1};
        triangle[1] = new int[]{4,3,2,1};
        triangle[2] = new int[]{3,2,1};
        triangle[3] = new int[]{2,1};
        triangle[4] = new int[]{1};

        System.out.println(triangle[0][1]); //第一行第二列数据:4
        System.out.println(triangle[4][0]); //第5行第1列数据:1
    }
}
